local zhongqu = fk.CreateSkill{
    name = "lingling__zhongqu",
    tags = {Skill.Compulsory}
}
Fk:loadTranslationTable{
    ["lingling__zhongqu"] = "终曲",
    [":lingling__zhongqu"] = "锁定技，当你进入濒死状态时，你判定，若为未因此判定过的花色，你回复体力至1点。",
    ["@[suits]lingling__zhongqu"] = "终曲",
}

zhongqu:addEffect(fk.EnterDying, {
    can_trigger = function(self, event, target, player, data)
        return target == player and player:hasSkill(zhongqu.name) and player.dying
    end,
    on_use = function (self, event, target, player, data)
        local room = player.room
        local mark = player:getTableMark("lingling__zhongqu")
        local parsePattern = table.concat(mark, ",")
        local judge = {
            who = player,
            reason = zhongqu.name,
            pattern = ".|.|" .. (parsePattern == "" and "." or "^(" .. parsePattern .. ")"),
        }
        room:judge(judge)
        room:addTableMarkIfNeed(player, "@[suits]lingling__zhongqu", judge.card.suit)
        if not table.contains(mark, judge.card:getSuitString()) and player.hp < 1 then
            room:recover{
                who = player,
                num = 1 - player.hp,
                recoverBy = player,
                skillName = zhongqu.name,
            }
        end
        table.insertIfNeed(mark, judge.card:getSuitString())
        room:setPlayerMark(player, "lingling__zhongqu", mark)
    end,
})

return zhongqu